﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Model
{
    /// <summary>
    /// 物品
    /// </summary>
    public abstract class Items : TdyxObjects
    {
        #region private data
        private ItemCategoryEnum itemCategory;//物品类别
        private ulong salePrice;//出售价格
        private bool binded = false;//是否已绑定
        private int stack = 1;//物品最大可堆叠数量
        private short grid = 1;//物品所占格子


        #endregion

        #region public fields

        /// <summary>
        /// 物品所占格子
        /// </summary>
        public short Grid
        {
            get { return grid; }
            set { grid = value; }
        }
        /// <summary>
        /// 物品最大可堆叠数量
        /// </summary>
        public int Stack
        {
            get { return stack; }
            set { stack = value; }
        }
        /// <summary>
        /// 是否已绑定
        /// </summary>
        public bool Binded
        {
            get { return binded; }
            set { binded = value; }
        }

        /// <summary>
        /// 出售价格
        /// </summary>
        public ulong SalePrice
        {
            get { return salePrice; }
            set { salePrice = value; }
        }

        /// <summary>
        /// 物品类别
        /// </summary>
        public ItemCategoryEnum ItemCategory
        {
            get { return itemCategory; }
            set { itemCategory = value; }
        }
        #endregion

        public Items() { }
        public Items(string name, byte[] code) : base(name, code) { }
    }

    /// <summary>
    /// 物品类别
    /// </summary>
    public enum ItemCategoryEnum
    {
        /// <summary>
        /// 有特别作用的物品，经验卡，免战牌等
        /// </summary>
        Special,
        /// <summary>
        /// 恢复类，恢复角色生命法力类的物品
        /// </summary>
        Recove,
        /// <summary>
        /// 增强类，增强角色属性的物品
        /// </summary>
        Strengthen,
        /// <summary>
        /// 强化类，强化、洗练装备的物品
        /// </summary>
        Reinforce,
        /// <summary>
        /// 任务物品，接受、完成任务获取的物品
        /// </summary>
        Mission,
        /// <summary>
        /// 装备
        /// </summary>
        Equip
    }

    /// <summary>
    /// 宝石类别
    /// </summary>
    public enum StoneCategory
    {
        /// <summary>
        /// 攻击
        /// </summary>
        ATK,
        /// <summary>
        /// 力量石
        /// </summary>
        STR,
        /// <summary>
        /// 敏捷石
        /// </summary>
        AGI,
        /// <summary>
        /// 智力石
        /// </summary>
        INT,
        /// <summary>
        /// 体力
        /// </summary>
        VIT,
        /// <summary>
        /// 防御
        /// </summary>
        AC,
        /// <summary>
        /// 生命
        /// </summary>
        HP,
        /// <summary>
        /// 暴击
        /// </summary>
        CRI,
        /// <summary>
        /// 破击
        /// </summary>
        DES,
        /// <summary>
        /// 命中
        /// </summary>
        HIT,
        /// <summary>
        /// 闪避
        /// </summary>
        DOD,
        /// <summary>
        /// 反击
        /// </summary>
        CS,
        /// <summary>
        /// 速度
        /// </summary>
        SPD
    }

    /// <summary>
    /// 人物游戏属性
    /// </summary>
    public enum AttributeEnum
    {
        /// <summary>
        /// 攻击
        /// </summary>
        ATK,
        /// <summary>
        /// 力量石
        /// </summary>
        STR,
        /// <summary>
        /// 敏捷石
        /// </summary>
        AGI,
        /// <summary>
        /// 智力石
        /// </summary>
        INT,
        /// <summary>
        /// 体力
        /// </summary>
        VIT,
        /// <summary>
        /// 防御
        /// </summary>
        AC,
        /// <summary>
        /// 生命
        /// </summary>
        HP,
        /// <summary>
        /// 暴击
        /// </summary>
        CRI,
        /// <summary>
        /// 破击
        /// </summary>
        DES,
        /// <summary>
        /// 命中
        /// </summary>
        HIT,
        /// <summary>
        /// 闪避
        /// </summary>
        DOD,
        /// <summary>
        /// 反击
        /// </summary>
        CS,
        /// <summary>
        /// 行动值
        /// </summary>
        SPD
    }

    /// <summary>
    /// 人物游戏属性
    /// </summary>
    public struct Attributes
    {
        /// <summary>
        /// 攻击
        /// </summary>
        public int ATK;
        /// <summary>
        /// 力量
        /// </summary>
        public int STR;
        /// <summary>
        /// 敏捷石
        /// </summary>
        public int AGI;
        /// <summary>
        /// 智力石
        /// </summary>
        public int INT;
        /// <summary>
        /// 体力
        /// </summary>
        public int VIT;
        /// <summary>
        /// 防御
        /// </summary>
        public int AC;
        /// <summary>
        /// 生命
        /// </summary>
        public int HP;
        /// <summary>
        /// 暴击
        /// </summary>
        public double CRI;
        /// <summary>
        /// 破击
        /// </summary>
        public double DES;
        /// <summary>
        /// 命中
        /// </summary>
        public double HIT;
        /// <summary>
        /// 闪避
        /// </summary>
        public double DOD;
        /// <summary>
        /// 反击
        /// </summary>
        public double CS;
        /// <summary>
        /// 行动值
        /// </summary>
        public double SPD;
    }

    /// <summary>
    /// 装备类别
    /// </summary>
    public enum EquipCategoryEnum
    {
        /// <summary>
        /// 头盔
        /// </summary>
        Helm,
        /// <summary>
        /// 胸甲
        /// </summary>
        Cuirass,
        /// <summary>
        /// 肩甲
        /// </summary>
        Pauldron,
        /// <summary>
        /// 腰带
        /// </summary>
        Belt,
        /// <summary>
        /// 下装
        /// </summary>
        Bottom,
        /// <summary>
        /// 武器
        /// </summary>
        Weapon,
        /// <summary>
        /// 戒指
        /// </summary>
        Ring,
        /// <summary>
        /// 项链
        /// </summary>
        Amulet
    }

    /// <summary>
    /// 宝石
    /// </summary>
    public class Stone : Items
    {
        private int level;//宝石等级

        /// <summary>
        /// 宝石等级
        /// </summary>
        public int Level
        {
            get { return level; }
            set { level = value; }
        }

        private Attribute attr;//增加的属性名称

        /// <summary>
        /// 增加的属性名称
        /// </summary>
        public Attribute Attr
        {
            get { return attr; }
            set { attr = value; }
        }
        private double rank;//增加的属性数值

        /// <summary>
        /// 增加的属性数值
        /// </summary>
        public double Rank
        {
            get { return rank; }
            set { rank = value; }
        }

        public Stone() { }
        public Stone(string name, byte[] code) : base(name, code) { }
    }

    /// <summary>
    /// 属性和数值
    /// </summary>
    public struct AttributeRank
    {
        /// <summary>
        /// 属性名称
        /// </summary>
        Attribute Attr;
        /// <summary>
        /// 属性数值
        /// </summary>
        double Rank;
    }

    /// <summary>
    /// 装备
    /// </summary>
    public class Equip : Items
    {
        #region private data
        private int needLv;//需要的等级
        private int attack;//攻击
        private int armourclass;//防御
        private int hp;//生命
        private int strength;//力量
        private int agility;//敏捷
        private int intelligence;//智力
        private int vitality;//体力
        private double criticalStrikes;//暴击值
        private double destroyShell;//破击值
        private StoneCategory[] canUseStone;//可镶嵌宝石的类别
        private double hit;//命中值
        private double dodge;//闪避值
        private double counterstrike;//反击值
        private double speed;//行动值
        private int hole;//宝石孔数
        private int increment;//强化值
        private EquipCategoryEnum equipCategory;//装备类别
        private Stone[] stones;//已经镶嵌的宝石
        private AttributeRank[] incrementAtt;//强化后增加的属性
        #endregion

        #region public fields

        /// <summary>
        /// 需要的等级
        /// </summary>
        public int NeedLV
        {
            get { return needLv; }
            set { needLv = value; }
        }

        /// <summary>
        /// 攻击
        /// </summary>
        public int ATK
        {
            get { return attack; }
            set { attack = value; }
        }

        /// <summary>
        /// 防御
        /// </summary>
        public int AC
        {
            get { return armourclass; }
            set { armourclass = value; }
        }

        /// <summary>
        /// 生命
        /// </summary>
        public int HP
        {
            get { return hp; }
            set { hp = value; }
        }

        /// <summary>
        /// 力量
        /// </summary>
        public int STR
        {
            get { return strength; }
            set { strength = value; }
        }

        /// <summary>
        /// 敏捷
        /// </summary>
        public int AGI
        {
            get { return agility; }
            set { agility = value; }
        }

        /// <summary>
        /// 智力
        /// </summary>
        public int INT
        {
            get { return intelligence; }
            set { intelligence = value; }
        }

        /// <summary>
        /// 体力
        /// </summary>
        public int VIT
        {
            get { return vitality; }
            set { vitality = value; }
        }

        /// <summary>
        /// 暴击值
        /// </summary>
        public double CRI
        {
            get { return criticalStrikes; }
            set { criticalStrikes = value; }
        }

        /// <summary>
        /// 破击值
        /// </summary>
        public double DES
        {
            get { return destroyShell; }
            set { destroyShell = value; }
        }

        /// <summary>
        /// 命中值
        /// </summary>
        public double Hit
        {
            get { return hit; }
            set { hit = value; }
        }


        /// <summary>
        /// 闪避值
        /// </summary>
        public double Dodge
        {
            get { return dodge; }
            set { dodge = value; }
        }

        /// <summary>
        /// 反击值
        /// </summary>
        public double Counterstrike
        {
            get { return counterstrike; }
            set { counterstrike = value; }
        }

        /// <summary>
        /// 行动值
        /// </summary>
        public double Speed
        {
            get { return speed; }
            set { speed = value; }
        }

        /// <summary>
        /// 宝石孔数
        /// </summary>
        public int Hole
        {
            get { return hole; }
            set { hole = value; }
        }

        /// <summary>
        /// 强化值
        /// </summary>
        public int Increment
        {
            get { return increment; }
            set { increment = value; }
        }

        /// <summary>
        /// 装备类别
        /// </summary>
        public EquipCategoryEnum EquipCategory
        {
            get { return equipCategory; }
            set { equipCategory = value; }
        }


        /// <summary>
        /// 可镶嵌宝石的类别
        /// </summary>
        public StoneCategory[] CanUseStone
        {
            get { return canUseStone; }
        }

        /// <summary>
        /// 已经镶嵌的宝石
        /// </summary>
        public Stone[] Stones
        {
            get { return stones; }
        }

        /// <summary>
        /// 强化后增加的属性
        /// </summary>
        public AttributeRank[] IncrementAtt
        {
            get { return incrementAtt; }
        }
        #endregion

        public Equip() { }
        public Equip(string name, byte[] code)
            : base(name, code) { }
    }
}
